<?php
/**
 * Created by PhpStorm.
 * User: gzc0918
 * Date: 2021-08-08
 * Time: 22:38
 */

namespace IMooc;


class Proxy implements IUserProxy
{
    function getUserName($id)
    {
        $db = Factory::getDatabase('slave');//模拟从读写分离的从库进行读操作
        return $db->query("select name from user where id=$id limit 1");
    }
    function setUserName($id, $name)
    {
        $db = Factory::getDatabase('master');//模拟从读写分离的主库进行写操作
        return $db->query("update user set name='$name' where id=$id limit 1");
    }
}